import numpy as np
import gradio as gr


def flip_text(x):
    return x[::-1]


def flip_image(x):
    return np.fliplr(x)


with gr.Blocks(analytics_enabled=False) as demo:
    gr.Markdown('Flip text or image files using this demo.')
    with gr.Tab('Flip Text'):
        text_input = gr.Textbox()
        text_output = gr.Textbox()
        text_button = gr.Button('Flip')
    with gr.Tab('Flip Image'):
        # with gr.Row():
        with gr.Column():
            image_input = gr.Image()
            image_output = gr.Image()
        image_button = gr.Button('Flip Image')
    with gr.Accordion('Open for more!'):
        gr.Markdown('Look at me ...')

    text_button.click(flip_text, inputs=text_input, outputs=text_output)
    image_button.click(flip_image, inputs=image_input, outputs=image_output)

demo.launch(server_name='0.0.0.0', server_port=7772, share=True)
